//
//  UINavigationController+TransitionAnimation.m
//  objective_c_language
//
//  Created by 王玉龙 on 2018/6/2.
//  Copyright © 2018年 longlong. All rights reserved.
//

#import "UINavigationController+TransitionAnimation.h"
#import <objc/runtime.h>
#import "TransitionAnimationScale.h"
#import "TransitionAnimationFlip.h"
#import "TransitionAnimationDrawer.h"
#import "TransitionAnimationWind.h"

@implementation UINavigationController (TransitionAnimation)


- (nullable id <UIViewControllerAnimatedTransitioning>) navigationController:(UINavigationController *)navigationController animationControllerForOperation:(UINavigationControllerOperation)operation fromViewController:(UIViewController *)fromVC toViewController:(UIViewController *)toVC
{
    if(self.transitionType == TransitionAnimationTypeFlip)
    {
        return [[TransitionAnimationFlip alloc] init];
    }
    else if(self.transitionType == TransitionAnimationTypeWind)
    {
        return [[TransitionAnimationWind alloc] init];
    }
    else if(self.transitionType == TransitionAnimationTypeScale)
    {
        return [[TransitionAnimationScale alloc] init];
    }
    else if(self.transitionType == TransitionAnimationTypeDrawer)
    {
        return [[TransitionAnimationDrawer alloc] init];
    }
    
    return nil;
}


- (void)setTransitionType:(TransitionAnimationType)transitionType
{
    objc_setAssociatedObject(self, @selector(transitionType), @(transitionType), OBJC_ASSOCIATION_RETAIN_NONATOMIC);
}

- (TransitionAnimationType)transitionType
{
    return [objc_getAssociatedObject(self, _cmd) intValue];
}


@end
